package com.spring.Path;

import java.io.FileNotFoundException;
import java.net.URL;

/**
 * Created by dong peng on 2018/3/13.
 */
public class UrlFind {

    public static void main(String[] args) throws FileNotFoundException {
        System.out.println(System.getProperty("user.dir"));
        URL filePath = UrlFind.class.getResource("/spring-context.xml");
        System.out.println(filePath.getFile());
        System.out.println(filePath.getPath());
        System.out.println(filePath.getHost());

        System.out.println("======================================================");
        filePath = UrlFind.class.getResource("spring-context.xml");

        if(filePath!= null) {
            System.out.println(filePath.getFile());
            System.out.println(filePath.getPath());
            System.out.println(filePath.getHost());
        }else {
            System.out.println(filePath);
        }



    }
}
